---
title: DynamoDB
editUrl: https://github.com/toolbeam/openauth/blob/master/packages/openauth/src/storage/dynamo.ts
description: Reference doc for the DynamoDB storage adapter.
---

import { Segment, Section, NestedTitle, InlineSection } from 'toolbeam-docs-theme/components'
import { Tabs, TabItem } from '@astrojs/starlight/components'

<div class="tsdoc">
<Section type="about">
Configure OpenAuth to use [DynamoDB](https://aws.amazon.com/dynamodb/) as a storage adapter.

```ts
import { DynamoStorage } from "@openauthjs/openauth/storage/dynamo"

const storage = DynamoStorage({
  table: "my-table",
  pk: "pk",
  sk: "sk"
})

export default issuer({
  storage,
  // ...
})
```
</Section>
---
## Methods
### DynamoStorage
<Segment>
<Section type="signature">
```ts
DynamoStorage(options)
```
</Section>
<Section type="parameters">
#### Parameters
- <p><code class="key">options</code> [<code class="type">DynamoStorageOptions</code>](#dynamostorageoptions)</p>
The config for the adapter.
</Section>
<InlineSection>
**Returns** <code class="type">StorageAdapter</code>
</InlineSection>
Creates a DynamoDB store.
</Segment>
## DynamoStorageOptions
<Segment>
<Section type="parameters">
- <p>[<code class="key">endpoint?</code>](#dynamostorageoptions.endpoint) <code class="primitive">string</code></p>
- <p>[<code class="key">pk?</code>](#dynamostorageoptions.pk) <code class="primitive">string</code></p>
- <p>[<code class="key">sk?</code>](#dynamostorageoptions.sk) <code class="primitive">string</code></p>
- <p>[<code class="key">table</code>](#dynamostorageoptions.table) <code class="primitive">string</code></p>
- <p>[<code class="key">ttl?</code>](#dynamostorageoptions.ttl) <code class="primitive">string</code></p>
</Section>
Configure the DynamoDB table that's created.
```ts
{
  table: "my-table",
  pk: "pk",
  sk: "sk"
}
```
</Segment>
<NestedTitle id="dynamostorageoptions.endpoint" Tag="h4" parent="DynamoStorageOptions.">endpoint?</NestedTitle>
<Segment>
<Section type="parameters">
<InlineSection>
**Type** <code class="primitive">string</code>
</InlineSection>
</Section>

<InlineSection>
**Default** "https://dynamodb.{region}.amazonaws.com"
</InlineSection>
Endpoint URL for the DynamoDB service. Useful for local testing.
</Segment>
<NestedTitle id="dynamostorageoptions.pk" Tag="h4" parent="DynamoStorageOptions.">pk?</NestedTitle>
<Segment>
<Section type="parameters">
<InlineSection>
**Type** <code class="primitive">string</code>
</InlineSection>
</Section>

<InlineSection>
**Default** "pk"
</InlineSection>
The primary key column name.
</Segment>
<NestedTitle id="dynamostorageoptions.sk" Tag="h4" parent="DynamoStorageOptions.">sk?</NestedTitle>
<Segment>
<Section type="parameters">
<InlineSection>
**Type** <code class="primitive">string</code>
</InlineSection>
</Section>

<InlineSection>
**Default** "sk"
</InlineSection>
The sort key column name.
</Segment>
<NestedTitle id="dynamostorageoptions.table" Tag="h4" parent="DynamoStorageOptions.">table</NestedTitle>
<Segment>
<Section type="parameters">
<InlineSection>
**Type** <code class="primitive">string</code>
</InlineSection>
</Section>
The name of the DynamoDB table.
</Segment>
<NestedTitle id="dynamostorageoptions.ttl" Tag="h4" parent="DynamoStorageOptions.">ttl?</NestedTitle>
<Segment>
<Section type="parameters">
<InlineSection>
**Type** <code class="primitive">string</code>
</InlineSection>
</Section>

<InlineSection>
**Default** "expiry"
</InlineSection>
The name of the time to live attribute.
</Segment>
</div>